<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:t="http://myfaces.apache.org/tomahawk">

<ui:composition	template="/layouts/CrudIncluirAlterar.xhtml">
	<ui:param name="bean" value="#{ManageInstrumentoConclusao}" />
	
	<ui:define name="breadcrumb_content">
		<h:outputLink value="/cpp-web/pages/cadastros.jsf" title="Cadastros">Cadastros</h:outputLink>
			<h:outputText> » </h:outputText>
		<h:outputLink value="#" styleClass="active">
			<h:outputText value="Incluindo Instrumento de Conclusão" rendered="#{bean.dadosForm.newRecord}"></h:outputText>
			<h:outputText value="Alterando Instrumento de Conclusão" rendered="#{not bean.dadosForm.newRecord}"></h:outputText>
		</h:outputLink>
	</ui:define>

	<ui:define name="quick_links">
		<ui:include src="/layouts/instrumento_conclusao_links.xhtml" />
	</ui:define>

	<ui:define name="CAMPOS">
		<fieldset id="dados">
		<span class="warning">* os itens marcados são obrigatórios</span>
			<ul>
				<li>
					<br />
					<h:outputLabel>
					    Aluno
						<span class="required">*</span>
					</h:outputLabel>
					<h:outputText value="#{bean.dadosForm.aluno.nome}" />
					<h:outputLink value="#" id="linkAluno">
					        (Alterar)
					        <rich:componentControl for="panelAluno" attachTo="linkAluno" operation="show" event="onclick"/>
				    </h:outputLink>
				</li>
				<li>
					<br />
					<br />
					<h:outputLabel>
					    Orientador
						<span class="required">*</span>
					</h:outputLabel>
					<h:outputText value="#{bean.dadosForm.orientador.nome}" />
					<h:outputLink value="#" id="linkOrientador">
					        (Alterar)
					        <rich:componentControl for="panelOrientador" attachTo="linkOrientador" operation="show" event="onclick"/>
				    </h:outputLink>
				</li>
				<li>
					<br />
					<br />
				</li>
				<li>
					<h:outputLabel value="Tipo do Instrumento de Conclusão:" ><span class="required">*</span></h:outputLabel>
					<h:selectOneMenu 
						value="#{bean.dadosForm.tipoInstrumentoConclusao}" converter="SimpleIndexConverter">
						<f:selectItem itemLabel="Selecione um Item" itemValue="#{null}" />
						<t:selectItems value="#{bean.tiposInstrumentoConclusao}" 
							itemLabel="#{item.nome}" itemValue="#{item}" var="item" />
					</h:selectOneMenu>
				</li>
				<li>
					<br />
					<h:outputLabel value="Título:" ><span class="required">*</span></h:outputLabel>
					<h:inputText value="#{bean.dadosForm.titulo}"/>
				</li>
				<li>
					<br />
					<h:outputLabel value="Descricao:" ><span class="required">*</span></h:outputLabel>
					<h:inputTextarea value="#{bean.dadosForm.descricao}"/>
				</li>
				<li>
					<br />
					<h:outputLabel value="Palavras-chave:" ><span class="required">*</span></h:outputLabel>
					<h:inputText value="#{bean.dadosForm.palavrasChave}"/>
				</li>
				<li>
					<br />
					<h:outputLabel value="Início:" ><span class="required">*</span></h:outputLabel>
					<rich:calendar value="#{bean.dadosForm.inicio}" />
				</li>
				<li>
					<br />
					<h:outputLabel value="Fim:" ><span class="required">*</span></h:outputLabel>
					<rich:calendar value="#{bean.dadosForm.fim}" />
				</li>
				<li>
					<h:panelGroup rendered="#{bean.dadosForm.finalizado}">
						<br />
						<h:outputLabel value="Finalizado?:" ></h:outputLabel>
						<h:selectBooleanCheckbox 
						value="#{bean.dadosForm.finalizado}" label="Finalizar Instrumento?" />
					</h:panelGroup>
				</li>
			</ul>
		</fieldset>
	</ui:define>
	
	<ui:define name="MODAL_PANEL">
		<rich:modalPanel id="panelAluno" width="700" height="400">
		        <f:facet name="header">
		            <h:panelGroup>
		                <h:outputText value="Selecione o Aluno"></h:outputText>
		            </h:panelGroup>
		        </f:facet>
		        <f:facet name="controls">
		            <h:panelGroup>
		                <h:graphicImage value="/images/close.png" styleClass="hidelink" id="hidelinkAluno"/>
		                <rich:componentControl for="panelAluno" attachTo="hidelinkAluno" operation="hide" event="onclick"/>
		            </h:panelGroup>
		        </f:facet>
		        
		        
				<h:form id="formPesquisarAluno">
					<fieldset id="dadosPesquisa">
						<div class="legenda"><span></span></div>
						<ul>
							<li> 
								<h:outputLabel value="Matrícula ou Nome do Aluno: " for="matricula" />
								<h:inputText value="#{bean.matriculaNomeAluno}" id="matricula" style="width: 300px; " />
							</li>
							<li>
								<a4j:commandButton actionListener="#{bean.filtrarAlunos}" value="Buscar Aluno" styleClass="btForm" 
								reRender="listaAlunos" />
							</li>
						</ul>
					</fieldset>
				 
				
					<br />
					
					<rich:dataTable id="listaAlunos" value="#{bean.alunos}" var="item" rows="5" styleClass="tb-comum listaPesquisa" rowClasses="cor1-row, cor2-row" >
						<h:column>
							<f:facet name="header">
								<h:outputText value="Matrícula" />
							</f:facet>
							<h:outputText value="#{item.matricula}" />
						</h:column>
						<h:column>
							<f:facet name="header">
								<h:outputText value="Nome" />
							</f:facet>
							<h:outputText value="#{item.nome}" />
						</h:column>
						<h:column>
							<f:facet name="header">
								<h:outputText value="Curso" />
							</f:facet>
							<h:outputText value="#{item.curso.nome}" />
						</h:column>
						<h:column headerClass="colunaAcoes">
						    <f:facet name="header">
                                 <h:outputText value="Ação"/>
                             </f:facet>								
							<h:commandLink actionListener="#{bean.doNothing}" immediate="true">
								<h:outputText value="Selecionar" />
								<f:setPropertyActionListener value="#{item}" target="#{bean.dadosForm.aluno}"/>					
							</h:commandLink>
						</h:column>
					</rich:dataTable>
					
					<t:saveState value="#{bean.alunos}"/>
				</h:form> 
		    </rich:modalPanel>
		    
		    
		    
		    <rich:modalPanel id="panelOrientador" width="700" height="400">
		        <f:facet name="header">
		            <h:panelGroup>
		                <h:outputText value="Selecione o Orientador"></h:outputText>
		            </h:panelGroup>
		        </f:facet>
		        <f:facet name="controls">
		            <h:panelGroup>
		                <h:graphicImage value="/images/close.png" styleClass="hidelink" id="hidelinkOrientador"/>
		                <rich:componentControl for="panelOrientador" attachTo="hidelinkOrientador" operation="hide" event="onclick"/>
		            </h:panelGroup>
		        </f:facet>
		        
		        
				<h:form id="formPesquisarOrientador">
					<fieldset id="dadosPesquisa">
						<div class="legenda"><span></span></div>
						<ul>
							<li> 
								<h:outputLabel value="Nome do Orientador: " for="nomeOrientador" />
								<h:inputText value="#{bean.nomeOrientador}" id="nomeOrientador" style="width: 300px; " />
							</li>
							<li>
								<a4j:commandButton actionListener="#{bean.filtrarOrientadores}" value="Buscar Orientador" styleClass="btForm" 
								reRender="listaOrientadores" />
							</li>
						</ul>
					</fieldset>
				 
				
					<br />
					
					<rich:dataTable id="listaOrientadores" value="#{bean.orientadores}" var="item" rows="5" styleClass="tb-comum listaPesquisa" rowClasses="cor1-row, cor2-row" >
						<h:column>
							<f:facet name="header">
								<h:outputText value="Nome" />
							</f:facet>
							<h:outputText value="#{item.nome}" style="#{item.disponivel ? 'color: blue;' : 'color: red;' }"/>
						</h:column>
						<h:column>
							<f:facet name="header">
								<h:outputText value="Perfil" />
							</f:facet>
							<h:outputText value="#{item.perfil}"  style="#{item.disponivel ? 'color: blue;' : 'color: red;' }"/>
						</h:column>
						<h:column headerClass="colunaAcoes">
						    <f:facet name="header">
                                 <h:outputText value="Ação"/>
                             </f:facet>								
							<h:commandLink actionListener="#{bean.doNothing}" immediate="true">
								<h:outputText value="Selecionar"  style="#{item.disponivel ? 'color: blue;' : 'color: red;' }" />
								<f:setPropertyActionListener value="#{item}" target="#{bean.dadosForm.orientador}"/>					
							</h:commandLink>
						</h:column>
					</rich:dataTable>
					
					<t:saveState value="#{bean.orientadores}"/>
				</h:form> 
		    </rich:modalPanel>
	</ui:define>
</ui:composition>

</html>
